

<!DOCTYPE HTML>
<html>
<head> 
<title>XMLHttpRequest Example</title> 
<script language="javascript"> 

var xmlhttp=false;
var ds="";

if (!xmlhttp && typeof XMLHttpRequest!='undefined') { 
	try {
      xmlhttp = new XMLHttpRequest();
    } catch (e) {
      xmlhttp = false;
    }
}

// this loadDoc uses proxy implmentation
// please run this application with PHP5+
function loadDocWithProxy() {
	var proxy = "./simpleproxy2.php";
	var word = document.forms[0].textArea1.value;
	document.forms[0].textArea2.value = word;
	document.forms[0].textArea1.value = '';
	
	alert(proxy + '?q='+word+ '&type=synonyms');
	
	if (xmlhttp)
	{
		alert("xmlhttp available");

		xmlhttp.open("GET", proxy + '?q='+word+ '&type=synonyms', true);
		xmlhttp.onreadystatechange=function() {
			if (xmlhttp.readyState==4)
			{
				if (xmlhttp.status==200)
				{
					ds=xmlhttp.responseText;
					
					document.forms[0].textArea2.value = ds;
				}
			}
		}
		xmlhttp.send(null);
	} else {
		alert("Cannot create a XHR instance");
	}
}

</script> 
<style> 
body, td {
	font-family: Arial;
	font-size: 13px;
	}
</style> 
</head> 
 
<body> 
<h1>Vocabulary-Test</h1> 
Enter a word:
<form name=form1> 
<textarea cols=50 rows=2 name=textArea1></textarea>
<input type=button value="Enter" onClick="loadDocWithProxy();">
<p><textarea cols = 60 rows = 7 name=textArea2> </textarea></p>
</form> 
 
 
<p><a href='index.html'>Example 1</a> | <a href='example2.html'>Example 2</a> 
  | <a HREF="indextimer.html">Example 3 with Timeout</a></p> 
 
<p><a href='http://bugninja.blogspot.com'>bugninja</a></p> 
 
</body> 
</html> 